<!DOCTYPE html>

<head>
    <meta charset="utf8">
    <title>模板指令</title>
    <script src="https://unpkg.com/vue@next"></script>
</head>

<body>
    <div id="myapp">
        <h1 v-bind:[prop]="name"  v-if="show">展示标题</h1>
        <!-- v-model  双向绑定-->
        <!-- v-参数后面还可以加修饰符 如下自动去掉收尾的空格 -->
        <input v-model.trim="content">
        <!-- v-on 和 v-bind 这两个指令使用的非常频繁,vue提供了缩写-->
        <!-- v-bind:id => :id -->
        <h2 :id="h2_id"></h2>
        <!-- v-on:click => @click -->
        <button @click='my_click("按钮被点击")'>按钮</button>
    </div>
    <script>
        const app = {
            data() {
                return {
                    show: true,
                    prop: "class",
                    name: "h1",
                    content:"",
                    h2_id:"h2"
                }
            },
            methods:{
                my_click:function(str){
                    alert(str);
                }
            }
        }
        Vue.createApp(app).mount("#myapp");
    </script>
    <style>
        #h1 {
            color: red;
        }

        .h1 {
            color: blue;
        }
    </style>
</body>